package com.haiheng.module_main.fragment

import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.Observer
import com.haiheng.common.fragment.RouterFragment
import com.haiheng.library.log.LogUtils
import com.haiheng.library_base.model.BaseViewModel
import com.haiheng.library_base.msg.MsgEvent
import com.haiheng.module_main.databinding.MainFragmentBinding


/**
 *
 * @Des:
 * @Author: hwz
 * @Date:2022/4/18 0018
 * @Version: 1.0
 */
class MainFragment : RouterFragment(){
    private val TAG: String = "MainFragment"
    private lateinit var binding: MainFragmentBinding
    private val observer = Observer<MsgEvent> { msgEvent ->
//        onMessageChange(msgEvent)
    }

    inner class ChildFragmentCallbacks : FragmentManager.FragmentLifecycleCallbacks() {
        override fun onFragmentResumed(fm: FragmentManager, f: Fragment) {
            super.onFragmentResumed(fm, f)

        }

        override fun onFragmentPaused(fm: FragmentManager, f: Fragment) {
            super.onFragmentPaused(fm, f)

            // dialogFragments/bottomsheetfragments closed
        }
    }

    // Register it on onCreate():
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        LogUtils.d("${TAG} registerFragmentLifecycleCallbacks")
        childFragmentManager.registerFragmentLifecycleCallbacks(ChildFragmentCallbacks(), false)
    }

    override fun onAttach(context: Context) {
        super.onAttach(context)

    }


    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        binding = MainFragmentBinding.inflate(inflater, container, false)

        return binding!!.root
    }


    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

    }

    override fun initView() {
    }

    override fun initViewModel(): BaseViewModel? {
      return null
    }

    override fun initLoad() {

    }


}